﻿/*
 * Copyright © 2020, Wuxi Safover Intelligent Technology Co., Ltd. All rights reserved.
 * 
 * 无锡安永智能科技有限公司版权所有，未经许可，不得用于商业用途
 * 
 * Visit: https://www.safover.com/ 
 */

using System;
using Safover.LidarCollector.Extensions;

namespace Ac.Bly
{
    public class Command
    {
        public CommandType CommandType { get; }

        public byte[] CmdInBytes { get; }

        public int LengthInBytes
        {
            get { return CmdInBytes.Length; }
        }

        public Command(byte[] cmdInBytes)
        {
            if (cmdInBytes == null)
            {
                throw new ArgumentNullException("cmdInBytes");
            }

            CommandType = CommandParas.GetCommandType(cmdInBytes[0]);


            CmdInBytes = cmdInBytes;
        }

        public override string ToString()
        {
            return CommandType.ToString();
        }

        public string GetAllDetails()
        {
            return $"{CommandType}, packet length=[{LengthInBytes}], [{PacketUtils.ToHexString(CmdInBytes)}].";
        }
    }

}